package com.health.mapp.impl;

import java.util.List;

import org.apache.log4j.Logger;

import com.health.db.dto.DoctorListDto;
import com.health.db.model.StuffListExample;
import com.health.db.service.user.IStuffListService;
import com.health.mapp.bean.Header;
import com.health.mapp.bean.RhnQueryDocListReq;
import com.health.mapp.bean.RhnQueryDocListResp;
import com.health.mapp.utils.Response;
import com.health.mapp.utils.ResultCode;

/**
 * Created by helili on 2017/2/20.
 */
public class RhnQueryDocListImpl implements ActionInterface {

    private Logger logger = Logger.getLogger(RhnQueryDocListImpl.class);
    private IStuffListService stuffListService ;
    @Override
    public Response execute(Header header, Object reqBean) throws Exception {

    	RhnQueryDocListReq req = (RhnQueryDocListReq) reqBean;
    	RhnQueryDocListResp resp = new RhnQueryDocListResp();

        Integer pageNo = req.getPageNo();
        Integer pageNum = req.getPageNum();
        
        req.getDepartmentId();

        if (null == pageNo || null == pageNum) {
        	resp.setErrorCode(ResultCode.OPERATION_LAKE_PARAMETER_ERROR);
        	resp.setErrorMsg(ResultCode.OPERATION_LAKE_PARAMETER_ERROR_NOTE);
            return resp;
        }
        
        StuffListExample example = new StuffListExample(); 
        //设置分页查询
        if(null!=pageNo&&null!=pageNum){
        	example.setOffset((pageNo.intValue()-1)*pageNum.intValue());
        	example.setPageSize(pageNum.intValue());
		}
        
        //设置部门
        example.setDepartmentid(req.getDepartmentId());
        //显示1
        example.setIsUserRegisterVisible((byte) 1);
        //在用 0
        example.setIsUsedFlag((short) 0);
        List<DoctorListDto> doctorListDtoList= stuffListService.selectByQueryDocReq(example);

        resp.setDocList(doctorListDtoList);
        resp.setPageNo(pageNo);
        resp.setPageNum(pageNum);
        return resp;
    }
	public IStuffListService getStuffListService() {
		return stuffListService;
	}
	public void setStuffListService(IStuffListService stuffListService) {
		this.stuffListService = stuffListService;
	}
    
    
}
